package com.example.fullexample.service.command;

import com.example.fullexample.util.ApplicationContextHolder;
import com.example.fullexample.util.Command;
import lombok.Getter;

public class DeleteStudentCommand implements Command {

    @Getter
    private Long id;

    private final DeleteStudentCommandHandler handler;

    public DeleteStudentCommand() {
        this.handler = ApplicationContextHolder.getApplicationContext()
                .getBean(DeleteStudentCommandHandler.class);
    }

    public DeleteStudentCommand(Long studentId) {
        this();
        this.id = studentId;
    }

    @Override
    public void execute() {
        handler.action(this);
    }
}
